﻿package cn.poco.service.impl;

import java.io.InputStream;
import java.util.List;
import android.util.Log;
import cn.poco.bean.Restaurant;
import cn.poco.service.INear;
import cn.poco.util.UrlConnectionUtil;
import cn.poco.util.xmlparse.RestaurantXmlparse;

public class NearImpl implements INear {

	private final static String TAG = "NearImpl";
	@Override
	public List<Restaurant> getResByGps(String citycode,double lat, double lon,
			int s, int l, int dis, int vouch, long dish, float d)
			throws Exception {
		InputStream inStream = null;
		StringBuffer sb = new StringBuffer();
			sb.append(BASE_GPS_RES_PATH);
			if(lat>0){
				sb.append("?lat=").append(lat);
			}
			if(lon>0){
				sb.append("&long=").append(lon);
			}
			if(citycode!=null && !citycode.equals("")){
				sb.append("&cd=").append(citycode);
			}
			if(s>=0){
				sb.append("&s=").append(s);
			}
			if(l>=0){
				sb.append("&l=").append(l);
			}
			if(dis==1){
				sb.append("&dis=").append(dis);
			}
			if(vouch==1){
				sb.append("&vouch=").append(vouch);
			}
			if(dish>0){
				sb.append("&dish=").append(dish);
			}
			if(d>0){
				sb.append("&d=").append(d);
			}
			Log.i(TAG, sb.toString());
			inStream = UrlConnectionUtil.getRequest(sb.toString());
			return RestaurantXmlparse.getXml(inStream);
	}

	

}
